package com.hmdp.test.lifecycle.event;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 创建一个事件监听器, 用来监听所有发布的事件
 *
 * @author lizhihui
 */
@Slf4j
@Component
public class StringEventListener implements ApplicationListener<StringEvent> {

    @Override
    public void onApplicationEvent(StringEvent event) {
        log.error("EVENT.监听到事件，内容={}, {}, {}, {}", event.getStr(), event.getSource(), DateUtil.date(event.getTimestamp()), event.getClass().getSimpleName());
    }

}
